#include "process_pool.hpp"

int main()
{
    Process_pool pool(4);
    pool.InitProcess_pool([](int fd)
                          {
    while(1)
    {
        int x = 0;
        ssize_t n = read(fd,&x,sizeof(x));
        if(n == sizeof(x))
        {
            std::cout << "该子进程pid: " << getpid() << " 执行任务: ";
            tasks[x]();
        }
        else if(n == 0)
        {
            std::cout << "该子进程退出:" << getpid() << std::endl;
            break;
        }
        else
        {
            std::cout << "读取失败" << std::endl;
            return false;
        }
    } });

    pool.In_turn_ctrl(10);
    pool.process_exit();
    return 0;
}
